home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / MacHaskell 2.2 / progs / demo / X11 / animation / r_shapes.hs < prev    next >
Encoding:
Text File  |  1994-09-27  |  1.3 KB  |  39 lines  |  [TEXT/YHS2]

  1. {-*****************************************************************
  2.   MODULE R_SHAPES
  3.   
  4.     This modules produces Pic's of boxes and triangles to help build
  5.   Pic's to animate.    
  6.     
  7. ******************************************************************-}
  8.  
  9. module R_Shapes (box, tri, circ_mov, circ) where
  10.  
  11. import R_Ptypes
  12. import R_Utility
  13. import R_Picture
  14. import R_Behaviour
  15.  
  16.   -- box takes four three ints, the color, width and height of the box and
  17.   -- returns a Pic of a box
  18. box :: Int -> Int -> Int -> Pic
  19. box c width height= [(c,[(0,0),(width,0),(width,height),(0,height),(0,0)])]
  20.  
  21.   -- tri takes a color and three vectors, and returns a Pic of a triangle
  22.   -- with the vectors as vertices
  23. tri:: Color -> Vec -> Vec -> Vec -> Pic
  24. tri c (x1,y1) (x2,y2) (x3,y3) = [(c,[(x1,y1),(x2,y2),(x3,y3),(x1,y1)])]
  25.  
  26.  
  27.   -- circ takes a color, the radius
  28. circ :: Color -> Int -> Int -> Pic
  29. circ c r inc = [(c,(r+r,r):(circ' r' inc' 1.0))]
  30.                where r' = (fromIntegral r)
  31.                      inc' = (fromIntegral inc)
  32.  
  33. circ' :: Float -> Float -> Float  -> [Vec]
  34. circ' r inc c | c>inc = []
  35. circ' r inc c         = vftov (x+r,y+r) : (circ' r inc (c+1.0))
  36.                     where x = r*(cos((2*c*pi)/inc))
  37.                                 y = r*(sin((2*c*pi)/inc))
  38.                     
  39.